import dom, { ajax, domg } from "../js/init.js";
import { obj } from "../js/index.js";
import header from "../js/header/eventhandle.js";

export function findtitle(e: any) {
  if (e.key === "Escape") {
    if (document.activeElement === dom.herder.findtitleipt) {
      (dom.herder.findtitleipt as any).value = "";
    }
  }
  if (e.key === "Enter") {
    if (document.activeElement === dom.herder.findtitleipt) {
      header.findtitle();
    }
  }
  if (e.key === "d" || e.key === "D") {
    if (dom.index.comment.classList.length <= 1)
      if (dom.index.shuoshuo.classList.length <= 1)
        if (dom.index.article.classList.length <= 1)
          if (dom.user.mubu.style.display === "none")
            dom.herder.findtitleipt.focus();
  }
}
document.addEventListener("scroll", function (this: HTMLElement, e: Event) {
  if (window.pageYOffset > 50) {
    domg("#r>.top2").style.transform = "translateY(41px)";
    // domg("#r>.top2").style.marginTop = "331px";
  } else {
    domg("#r>.top2").style.transform = "translateY(0)";

    // domg("#r>.top2").style.marginTop = "290px";
  }
});
domg("#scroll").addEventListener(
  "click",
  function (this: HTMLElement, e: Event) {
    window.scroll(0, 0);
  }
);
